package xyz.riceball.develop.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import xyz.riceball.develop.entity.po.InoutParamPO;
import xyz.riceball.develop.service.InoutParamService;
import xyz.riceball.framework.core.bean.ApiController;
import xyz.riceball.framework.core.bean.ApiR;
import xyz.riceball.framework.core.bean.ApiRc;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;


/**
 * 输入输出参数 控制层
 *
 * @author xiaovcloud
 * @since 2022-07-02 10:58:37
 */
@Deprecated
@RestController
@RequestMapping("/rb/api/develop/inoutparam")
public class InoutParamController extends ApiController {

    @Resource
    private InoutParamService inoutParamService;

    /**
     * 查询所有的输入输出条件
     *
     * @param inoutParamPO 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "查询所有的输入输出条件")
    @GetMapping
    public ApiR<List<InoutParamPO>> selectAll(InoutParamPO inoutParamPO) {
        return success(inoutParamService.selectAll(inoutParamPO));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询输入输出条件")
    @GetMapping("{id}")
    public ApiR<InoutParamPO> selectOne(@PathVariable Serializable id) {
        return success(inoutParamService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param inoutParamPO 实体对象
     * @return 新增结果
     */
    @ApiOperation(value = "新增输入输出条件")
    @PostMapping
    public ApiR<InoutParamPO> insert(@RequestBody InoutParamPO inoutParamPO) {
        return inoutParamService.add(inoutParamPO);
    }

    /**
     * 修改数据
     *
     * @param inoutParamPO 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改输入输出条件")
    @PutMapping
    public ApiR<Void> update(@RequestBody InoutParamPO inoutParamPO) {
        boolean edit = inoutParamService.edit(inoutParamPO);
        return ApiR.msg(edit, "修改条件成功", "修改条件失败");
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @ApiOperation(value = "删除输入输出条件")
    @DeleteMapping
    public ApiRc<Void> delete(@RequestBody List<String> ids) {
        return inoutParamService.delete(ids);
    }


}
